#include once "mud-gui/ui.bi"
#include once "mud-gui/widgets/GridLayout.bi"
#include once "mud-gui/widgets/Label.bi"

'Example program testing GridLayout and label
using ui
SLOT(label_click)
	var lbl = cast(Label ptr, ref)
	ConsolePrint( (lbl->text) & " clicked" )
	return 1
ENDSLOT

dim as GridLayout ptr mw
dim as label ptr label1, label2, label3, label4, label5

if initScreen("GridLayout and Label Example") = 0 then
	print "unable to initialize screen."
	end 23
end if

mw = new GridLayout

label1 = new label
label1->setText = "Label 1"

label2 = new label
label2->setText = "Label 2"

label3 = new label
label3->setText = "Label 3"
connectSignal( label3, clicked, label_click)
'              ^       ^        ^
'              |       |        + The SLOT to call when this signal is triggered.
'              |       + The signal you wish to catch.
'              + The object whose signal you want to catch.

label4 = new label
label4->setText = "Label 4"
label5 = new label
label5->setText = "Label 5"

mw->sizeGrid(4,4)

ConsolePrint( "1: " & mw->placeWidget( toBaseWidget(label1), 1, 1 ) )
ConsolePrint( "2: " & mw->placeWidget( toBaseWidget(label2), 2, 2 ) )
ConsolePrint( "3: " & mw->placeWidget( toBaseWidget(label3), 3, 2, 4, 4 ) )
ConsolePrint( "4: " & mw->placeWidget( toBaseWidget(label4), 3, 1, 4, 1 ) )
ConsolePrint( "5: " & mw->placeWidget( toBaseWidget(label5), 1, 3, 2, 4 ) )

end RunGUI( toBaseWidget(mw) )
